package com.clkj.cldisabledmanclient.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.clkj.cldisabledmanclient.R;
import com.clkj.cldisabledmanclient.app.AppManager;
import com.clkj.cldisabledmanclient.util.Res;

/**
 * Created by clboys on 2019/5/8.
 */

public abstract class BaseActivity extends AppCompatActivity
{

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {

        AppManager.getAppManager().addActivity(this);
        super.onCreate(savedInstanceState);
    }


    private RelativeLayout rlTitle;



    private ImageView ivBack;
    private TextView tvTitle;
    private TextView tvRight;



    public void initTitle(Integer backgroundResId, Integer titleColorResId, String title, boolean isLeftBack, String rightTvStr) {
        rlTitle = (RelativeLayout) findViewById(R.id.rl_title);
        ivBack = (ImageView) findViewById(R.id.iv_back);
        tvTitle = (TextView) findViewById(R.id.tv_title);
        tvRight = (TextView) findViewById(R.id.tv_right);


        if (null != backgroundResId) {
            rlTitle.setBackgroundResource(backgroundResId);
        }

        if (null != titleColorResId) {
            tvTitle.setTextColor(Res.getColor(titleColorResId));
        }

        tvTitle.setText(title);

        if (isLeftBack == true) {
            ivBack.setVisibility(View.VISIBLE);
            ivBack.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
        }

        if (null != rightTvStr) {
            tvRight.setText(rightTvStr);
            tvRight.setVisibility(View.VISIBLE);
        }

    }




    public abstract void initData();

    public abstract void assignView();

    public abstract void initView();











}
